<!-- 订单消息 -->
<template>
	<view>
		<u-navbar :isFixed="true" title="订单消息" :borderBottom="false"></u-navbar>
		<block v-for="(item,index) in list" :key="index">
			<!-- <view class="timeline">{{item.content.createtime}}</view> -->
			<view class="card" @click="goDetail(item.content.order_id,item.content.type)">
				<view class="title flex_bet_align">
					<view class="">{{item.content.title}}</view>
					<view class="fz14">{{item.content.createtime}}</view>
				</view>
				<view class="flex_align">
					<image class="goodsImg" :src="item.content.image"></image>
					<view class="orderDetail">
						<view>{{item.content.goods_title}}</view>
						<view class="clamp1" v-if="item.content.order_sn">订单编号：{{item.content.order_sn}}</view>
						<view class="clamp1" v-if="item.content.logistics_name">物流公司：{{item.content.logistics_name}}
						</view>
						<view class="clamp1" v-if="item.content.logistics_order_sn">
							物流单号：{{item.content.logistics_order_sn}}
						</view>
					</view>
				</view>
			</view>
		</block>
		<view class="not_more" v-if="list.length<1">
			<image src="../static/img/wxiaoxi.png" mode="widthFix"></image>
			<view class="text">暂无消息</view>
		</view>
		<view class="nomore" v-if="nomore&&list.length>0">—— · 没有更多了 · ——</view>
	</view>
</template>

<script>
	var _this, $paginator;
	export default {
		data() {
			return {
				list: [],
				nomore: false,
				// 回到头部按钮距离
				scrollTop: 0,
			}
		},
		onLoad(e) {
			_this = this
			$paginator = new _this.$paginator(_this.$api)
			_this.getdata(true)
		},
		//监听页面滚动
		onPageScroll(res) {
			this.scrollTop = res.scrollTop
		},
		//下拉刷新
		onPullDownRefresh() {
			$paginator = new _this.$paginator(_this.$api)
			_this.getdata(true)
		},
		onReachBottom: function() {
			$paginator.nextPager(() => {
				_this.getdata()
			})
		},
		methods: {
			getdata: function(firstLoad = false) {
				$paginator.getData('ordmessagelist', {
					type: 2
				}, (data) => {
					if (firstLoad) {
						_this.list = data.list ? data.list : []
					} else {
						_this.list = _this.list.concat(data.list)
					}
					_this.nomore = data.nomore
				})
			},

			// 跳转到详情
			goDetail(id, type) {
				console.log(type)
				if (type == 1 || type == 5) {
					uni.navigateTo({
						url: "/personal/appointmentDetail?id=" + id + "&type=0"
					})
				} else if (type == 2) {
					uni.navigateTo({
						url: "/personal/orderDetail?type=0&id=" + id
					})
				} else if (type == 3) {
					uni.navigateTo({
						url: "/personal/afterSalesDetail?type=0&id=" + id
					})
				} else if (type == 4) {
					uni.navigateTo({
						url: "/personal/offerList?id=" + id
					})
				}


			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F3F3F3;
	}

	.timeline {
		height: 90rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC-Medium;
		font-weight: 500;
		text-align: center;
		color: #666666;
		line-height: 90rpx;
	}

	.card {
		width: 700rpx;
		height: 300rpx;
		background: #ffffff;
		border-radius: 12rpx;
		margin: 0 auto;
		padding: 34rpx 19rpx;

		.title {
			font-size: 30rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: left;
			color: #000000;
			margin-bottom: 24rpx;
		}

		.goodsImg {
			width: 180rpx;
			height: 180rpx;
			background-color: #EEEEEE;
			margin-right: 24rpx;
		}

		.orderDetail {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC-Medium;
			font-weight: 500;
			text-align: left;
			color: #666666;
			line-height: 48rpx;
		}
	}
</style>
